package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.example.common.Result;
import com.example.entity.User;
import com.example.mapper.UserMapper;
import com.example.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


/**
 * <p>
 *  服务实现类
 * </p>
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Resource
    private UserMapper userMapper;
    @Override
    public IPage pageC(IPage<User> page) {
        return userMapper.pageC(page);
    }

    @Override
    public IPage pageCC(IPage<User> page, Wrapper wrapper) {
        return userMapper.pageCC(page,wrapper);
    }
/*
* 单项删除
*
* */
    @Override
    public Result Delete(String id) {
        Boolean delete = userMapper.Delete(id);
        if (delete != true){
            return Result.fail2("删除失败");
        }
        return Result.suc();
    }
    /*
    * 批量删除
    * */
    @Override
    public Result DeleteByIds(Long[] ids) {
        for (Long id : ids) {
            Boolean delete = userMapper.Delete(id.toString());
            if (delete != true){
                return Result.fail2("删除失败");
            }
        }
        return Result.suc();
    }
}
